package com.campus.controller;

import com.campus.common.Result;
import com.campus.domain.Dto.CourseCreateDto;
import com.campus.service.ICourseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/course")
@Slf4j
public class CourseController {

    @Autowired
    private ICourseService courseService;

    @PostMapping("/add")
    public Result addCourse(@RequestBody @Validated CourseCreateDto courseCreateDto){
        int rs = courseService.addCourse(courseCreateDto);
        return rs == 1 ? Result.success() : Result.error();
    }

}
